<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">

  <title>接口文档</title>
  <link href="./markdown.css" rel="stylesheet">
    <style type="text/css">
        .hide_a{
            width: 260px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            display: block;
            float: left;
        }
    </style>
</head>

<body>
<?php
$k = isset($_GET['k']) ? urldecode($_GET['k']) : '';
$file = '';
if($k != ''){
	$file = './model/'.urldecode($k);
}
if (file_exists($file)) {
	include './Parsedown.php';
	$markdown = file_get_contents($file);
	$info = Parsedown::instance()
	 	->setUrlsLinked(true)
	   	->text($markdown);
?>
<div class="left">
    <a href="/"><span style="font-size: 20px;">文档列表</span> > <?php echo $k;?> </a>
    <a style="text-decoration:none;">------------------------------------------</a>
</div>
<div class="right">
	<?php echo $info;?>
</div>
<script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript">
$(function(){
	$('h1,h2,h3').each(function(){
		$(this).attr('name','mao'+$(this).index());
		$(this).attr('id','mao'+$(this).index());
		$(".left").append("<a href='#mao"+$(this).index()+"' class='hide_a'>"+this.innerHTML+"</a>");
	})
})
</script>
<?php
} else {
	echo "<table style='margin:0 auto;width:50%;' align='center'><tr><td align='center' style='font-size:30px;'>===》文档列表《===</td></tr>";
	$dir = scandir('./model');
	foreach ($dir as $k => $v) {
		if($v != '.' && $v != '..'){
			echo "<tr><td align='center' style='font-size:20px;'><a href='?k=".urlencode($v)."'>".$v."</a></td></tr>";
		}
	}
	echo "</table>";
}
?>
</body>
</html>